package com.ruoyi.web.controller.villagers;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.villagers.domain.VigHouse;
import com.ruoyi.villagers.service.IVigHouseService;
import com.ruoyi.villagers.service.IVigReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/villagers/review")
public class VigReviewController extends BaseController {

    @Autowired
    private IVigReviewService iVigReviewService;


    /**
     * 通过申请
     */
    @PreAuthorize("@ss.hasPermi('villagers:review:pass')")
    @PutMapping("/pass/{houseIds}")
    public AjaxResult pass(@PathVariable Long[] houseIds){

        return toAjax(iVigReviewService.passReviews(houseIds));
    }


    /**
     * 拒绝申请
     */
    @PreAuthorize("@ss.hasPermi('villagers:review:fail')")
    @PutMapping("/fail/{houseIds}")
    public AjaxResult fail(@PathVariable Long[] houseIds){

        return toAjax(iVigReviewService.failReviews(houseIds));
    }

    /**
     * 获取建房列表信息
     */

    @PreAuthorize("@ss.hasPermi('villagers:review:list')")
    @GetMapping("/list")
    public TableDataInfo list(VigHouse house){
        startPage();
        List<VigHouse> list = iVigReviewService.selectHasReviewList(house);
        return getDataTable(list);
    }


}
